<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改sms用户信息')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form class="form-horizontal" id="form-user-edit" th:object="${user}">
        <input name="id"  type="hidden"  th:field="*{id}" />
        <input name="wardCode"  type="hidden"  th:field="*{wardCode}" id="treeId"/>
        <h4 class="form-header h4">用户信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-2 control-label">工号：</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="text" readonly="true" th:field="*{userId}"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-2 control-label is-required">姓名：</label>
                    <div class="col-sm-4">
                        <input name="name" placeholder="病人姓名" class="form-control" type="text" maxlength="30"
                               th:field="*{userName}" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-2 control-label is-required">手机号码：</label>
                    <div class="col-sm-4">
                        <div class="input-group">
                            <input name="phoneNumber" placeholder="请输入手机号码" class="form-control" type="text"
                                   maxlength="11" th:field="*{telphone}">
                            <span class="input-group-addon"><i class="fa fa-mobile"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-2 control-label is-required">归属部门：</label>
                    <div class="col-sm-4">
                        <div class="input-group">
                            <input class="form-control" type="text" name="wardName" onclick="selectDeptTree()" id="treeName" th:field="*{wardName}" required>
                            <span class="input-group-addon"><i class="fa fa-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-2 control-label">用户状态：</label>
                    <div class="col-sm-4">
                        <label class="toggle-switch switch-solid">
                            <input type="checkbox" id="enable" th:checked="${user.enable == '1' ? true : false}">
                            <span></span>
                        </label>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-2 control-label is-required">职级：</label>
                    <div class="col-sm-4">
                        <select class="form-control" name="level" th:field="*{level}">
                            <option value="">--请选择职级--</option>
                            <option value="chiefnurse">护士长</option>
                            <option value="chiefcharge">收费处主任</option>
                        </select>
                    </div>

                </div>
            </div>
        </div>
    </form>
</div>
<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script type="text/javascript">

    var prefix = ctx + "pub/sms";
    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-user-edit").serializeArray();
            $.operate.saveTab(prefix + "/edit", data);
        }
    }

    /*用户管理-修改-选择部门树*/
    function selectDeptTree() {
        var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        if ($.tree.notAllowParents(tree)) {
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    }

</script>
</body>
</html>